package lanou.giftsay_01.main.categorymain;

import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;

import lanou.giftsay_01.R;
import lanou.giftsay_01.adapter.FenggeRvAdapter;
import lanou.giftsay_01.bean.NormalBean;
import lanou.giftsay_01.tools.BaseActivity;
import lanou.giftsay_01.tools.NetTool;
import lanou.giftsay_01.tools.URLValues;

/**
 * Created by dllo on 16/8/22.
 */
public class DuixiangActivity extends BaseActivity {

    private FenggeRvAdapter fenggeRvAdapter;
    private RecyclerView rv;
    private ImageView imageView;

    @Override
    protected int setLayout() {
        return R.layout.duxiang_acitivity;
    }

    @Override
    protected void initView() {
        rv = (RecyclerView) findViewById(R.id.duixiang_activity_rv);
        imageView = (ImageView) findViewById(R.id.search_backthree);
        GridLayoutManager manager = new GridLayoutManager(getApplicationContext() , 2);
        fenggeRvAdapter = new FenggeRvAdapter(this);
        rv.setLayoutManager(manager);
    }

    @Override
    protected void initDate() {

        NetTool netTool = new NetTool();
        netTool.getNetData(URLValues.WANGGE, NormalBean.class, new NetTool.NetListener<NormalBean>() {
            @Override
            public void onSuccess(NormalBean normalBean) {

                fenggeRvAdapter.setNormalBean(normalBean);
                fenggeRvAdapter.setTag(2);
                rv.setAdapter(fenggeRvAdapter);
            }

            @Override
            public void onError(String errorMsg) {

            }
        });
       imageView.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               finish();
           }
       });
    }
}
